package com.example.demo.Test;

import org.apache.ibatis.jdbc.SQL;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * 其他测试
 *
 * @author Create by 崔少良 2018-06-08 下午 1:19
 */
public class OtherTest {
    public static void main(String[] args) {
        A a = new A();
        getM(null);
    }
    public static void getM(A a){
        a.setA("");
        System.out.println(a==null);
    }
    static String selectSql(){
        return new SQL(){{
            SELECT("*");
            FROM("mst_user");
            WHERE("1=1");
        }}.toString();
    }
    static String selectSQL(){
        return new SQL(){{
            SELECT("P.ID, P.USERNAME, P.PASSWORD, P.FULL_NAME");
            SELECT("P.LAST_NAME, P.CREATED_ON, P.UPDATED_ON");
            FROM("PERSON P");
            FROM("ACCOUNT A");
            INNER_JOIN("DEPARTMENT D on D.ID = P.DEPARTMENT_ID");
            INNER_JOIN("COMPANY C on D.COMPANY_ID = C.ID");
            WHERE("P.ID = A.ID");
            WHERE("P.FIRST_NAME like ?");
            OR();
            WHERE("P.LAST_NAME like ?");
            GROUP_BY("P.ID");
            HAVING("P.LAST_NAME like ?");
            OR();
            HAVING("P.FIRST_NAME like ?");
            ORDER_BY("P.ID");
            ORDER_BY("P.FULL_NAME");
        }}.toString();
    }
    static void MapTest(){
        Map map = new HashMap();
        map.put("a","1");
        map.put("b","2");
        System.out.println( map.keySet());
    }
    static void ClassTest(String[] args){
        Class<?> c1 = null;
        try {
            c1 = Class.forName(args[0]);
        }catch (ClassNotFoundException e){
            System.out.println("Class not found.");
            System.exit(1);
        }
        Set<String> s = null;
        try{
            s = (Set<String>) c1.newInstance();
        } catch (IllegalAccessException e) {
            System.out.println("Class not accessible");
            System.exit(1);
        } catch (InstantiationException e) {
            System.out.println("Class not instantiable");
            System.exit(1);
        }
        s.addAll(Arrays.asList(args).subList(1,args.length));
        System.out.println(s);
    }
    static void LongTest(){
        long sum = 0L;
        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            sum += i;
        }
        System.out.println(sum);
    }
    static Integer ig;
    static int i;
    static String s;
    static void test(){
        BigDecimal bd1 = new BigDecimal(1.00);
        BigDecimal bd2 = new BigDecimal(0.90);
        System.out.println(bd1.subtract(bd2));
        if (i==10)System.out.println("------------");
        if (s == null) System.out.println("**********");
        System.out.println(Integer.MAX_VALUE+":"+Integer.MIN_VALUE);
        System.out.println("q"+"3"+4);
        StringBuilder sb = new StringBuilder(100);
        System.out.println(sb.append("q").append("3").append(4));
        System.out.println(new HashMap<>());
    }
}
class A{
    private String a;
    private String b;

    public String getA() {
        return a;
    }

    public void setA(String a) {
        this.a = a;
    }

    public String getB() {
        return b;
    }

    public void setB(String b) {
        this.b = b;
    }
}
